Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix index out of range error when no timestamp in log #1215

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

TheRealHaoLiu
Copy link
Member

PR #1187 introduced a situation that causes

panic: runtime error: index out of range [1] with length 1

goroutine 534519 [running]:
github.com/ansible/receptor/pkg/workceptor.(*KubeUnit).kubeLoggingWithReconnect(0xc001506b00, 0xc004a97400?, 0xc009cb9fd0?, 0xc00cd1d510, 0xc00cd1d520)
        /Users/haoli/projects/src/github.com/TheRealHaoLiu/receptor/pkg/workceptor/kubernetes.go:395 +0x108b
created by github.com/ansible/receptor/pkg/workceptor.(*KubeUnit).runWorkUsingLogger
        /Users/haoli/projects/src/github.com/TheRealHaoLiu/receptor/pkg/workceptor/kubernetes.go:834 +0xc5e

This PR will write the whole line into stdout if first word in the log is not an timestamp

This can both prevent the index out of range error and allow us to record the line in stdout to aid further debugging of this issue.

PR ansible#1187 introduced a situation that causes

```
panic: runtime error: index out of range [1] with length 1

goroutine 534519 [running]:
github.com/ansible/receptor/pkg/workceptor.(*KubeUnit).kubeLoggingWithReconnect(0xc001506b00, 0xc004a97400?, 0xc009cb9fd0?, 0xc00cd1d510, 0xc00cd1d520)
        /Users/haoli/projects/src/github.com/TheRealHaoLiu/receptor/pkg/workceptor/kubernetes.go:395 +0x108b
created by github.com/ansible/receptor/pkg/workceptor.(*KubeUnit).runWorkUsingLogger
        /Users/haoli/projects/src/github.com/TheRealHaoLiu/receptor/pkg/workceptor/kubernetes.go:834 +0xc5e
```

This PR will write the whole line into stdout if first word in the log is not an timestamp

This can both prevent the index out of range error and allow us to record the line in stdout to aid further debugging of this issue.

Co-Authored-By: Matthew Sandoval <[email protected]>
Copy link

sonarcloud bot commented Nov 19, 2024

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 44.19%. Comparing base (ded8059) to head (e3a1c78).
Report is 1 commits behind head on devel.

Files with missing lines Patch % Lines
pkg/workceptor/kubernetes.go 0.00% 7 Missing ⚠️
@@            Coverage Diff             @@
##            devel    #1215      +/-   ##
==========================================
+ Coverage   43.82%   44.19%   +0.36%     
==========================================
  Files          33       36       +3     
  Lines        8178     8759     +581     
==========================================
+ Hits         3584     3871     +287     
- Misses       4320     4615     +295     
+ Partials      274      273       -1     
Files with missing lines Coverage Δ
pkg/workceptor/kubernetes.go 21.55% <0.00%> (-0.02%) ⬇️

... and 4 files with indirect coverage changes

Components Coverage Δ
Go 43.83% <0.00%> (+<0.01%) ⬆️
Receptorctl 49.31% <ø> (∅)

🚨 Try these New Features:

@matoval matoval merged commit 2c1da19 into ansible:devel Nov 19, 2024
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants